package handler;

import lombok.Data;
import model.LeaveRequest;

@Data
public abstract class Handler {

    protected final static int NUM_ONE = 1;
    protected final static int NUM_THREE = 3;
    protected final static int NUM_SEVEN = 7;

    private int numStart;
    private int numEnd;

    //声明后继者
    private Handler nextHandler;

    public Handler(int numStart, int numEnd) {
        this.numStart = numStart;
        this.numEnd = numEnd;
    }

    public Handler setNextHandler(Handler nextHandler) {
        return this.nextHandler = nextHandler;
    }

    //各级领导处理方法
    protected abstract void handlerLeave(LeaveRequest leave);
    //提交请求条
    public final void submit(LeaveRequest leave){
        this.handlerLeave(leave);
        if(this.nextHandler!=null && leave.getNum() > this.numEnd){
            //超过了，所以提交给上级领导
            this.nextHandler.submit(leave);
            return;
        }
        System.out.println("审批流程完成");
    }
}
